import java.io.*;
import java.net.Socket;

/**
 * 内网
 * 关闭socket的流会导致socket关闭
 * Created by zhoub on 2019/12/9.
 */
public class VedioSocketClient {
    public static void main(String[] args) throws IOException {
        String host = "10.0.65.211";
        int port = 8081;
        Socket socket = new Socket(host,port);
        while(true){
            //vedio flush
            File file = new File("D:\\cma\\test.mp4");
            OutputStream os = socket.getOutputStream();
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
            byte[] bs = new byte[1024*1024*8]; //8MB
            int len = 0;
            while ((len = bis.read(bs)) != -1) {
                System.out.println(len);
                os.write(bs,0,len);
            }
            // close
            bis.close();
            os.flush();
            os.close();
            socket.close();
        }
    }
}
